

/**
 *
 * @param {[]} arr
 * @param {number} n
 */
function sortMerge(arr, n) {
    const leftArr = arr.slice(0, n);
    const rightArr = arr.slice(n, arr.length);
    const temp = [];
    let left = 0;
    let right = 0;

    while(leftArr.length > left) {
        if (leftArr[left] < rightArr[right]) {
            temp.push(rightArr[right]);
            right++;
        } else {
            temp.push(leftArr[left]);
            left++;
        }
    }

    return temp.concat(rightArr.slice(right, rightArr.length));
}


console.log("%c Line:64 🍎", "color:#ea7e5c", sortMerge([30, 24, 43, 33, 25, 11, 1], 2));

/**
 *
 * @param {string} one
 * @param {string} two
 */
function stringAdd(one, two) {
    let long = '';
    let short = '';
    if (one.length > two.length) {
        long = one;
        short = two;
    } else {
        long = two;
        short = one;
    }

    let result = [];

    for (let index = 0; index < long.length; index++) {
        let longStr = long[long.length - index - 1];
        let shortStr = short[short.length - index - 1] || 0;
        let resultStr = result[result.length - index - 1] || 0;
        let sum = longStr * 1 + shortStr * 1 + resultStr * 1;

        if (result[result.length - index - 1]) {
            if (sum >= 10) {
                result[result.length - index - 1] = sum.toString(10)[1];
                result.unshift('1');
            } else {
                result[result.length - index - 1] = sum;
            }
        } else {
            result.unshift(...String(sum).split(''));
        }

    }

    return result.join('');
}


console.log("%c Line:104 🥒", "color:#e41a6a", stringAdd('999999', '99'));

function dfc(index) {
  if (index === 5) {
    return index;
  }

  index ++;
  return dfc(index);
}

console.log("%c Line:84 🌶 dfc(0)", "color:#93c0a4", dfc(0));
